<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function fn1() {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve(111)
                    // reject(111)
                }, 1000)
            })
        }
        function fn2(){
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve(222)
                    // reject(222)
                }, 2000)
            })
        }

        function fn3(){
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve(333)
                    // reject(333)
                }, 3000)
            })
        }

        // fn1().then(res=>{
        //     console.log(res);
        //     return fn2()
        // }).then(res=>{
        //     console.log(res);
        //     return fn3()
        // }).then(res=>{
        //     console.log(res);
        // })

        async function as(){
            try{
                let p1 = await fn1();
                console.log(p1);
                let p2 =await fn2();
                console.log(p2);
                let p3 =await fn3();
                console.log(p3);
            }catch(err){
                console.log('err',err);
            }
        }
        as()

        // 循环的情况
        let arr = [fn1,fn2,fn3]
        async function ass(arr){
            for(let val of arr){
                await val()
            }
        }
        ass(arr)
    </script>
</body>
</html>